﻿<%@ Page Title="Information Management System" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="EventManage.aspx.cs" Inherits="CARMS.Admin.EventManage" %>

<%@ Import Namespace="CARMSBusiness.InterFace" %>
<%@ Register Src="~/Controls/GridPager.ascx" TagName="GridPager" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script language="javascript" type="text/javascript">
        function showEventView(eventId) {
            $dialog('<%= ResolveUrl("~/Admin/EventView.aspx") %>?EventId=' + eventId, { width: 500, height: 500 });
        }
        function treeCategoriesSelectedNodeChanged() {
            $get('<%=btnChangeCategory.ClientID %>').click();
        }

        function showBulkDelete() {
            $dialog('<%= ResolveUrl("~/Admin/EventBulkDelete.aspx") %>', { width: 300, height: 140 }, function(result) {
                if (result) {
                    $get('<%=btnSearch.ClientID %>').click();
                }
            });
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel runat="server">
        <ContentTemplate>
            <table border="0" cellpadding="5" cellspacing="5" style="width: 100%">
                <tr>
                    <td valign="top" style="width: 120px">
                        <NineRays:FlyTreeView ID="treeCategories" runat="server" DrawLines="False" OnSelectedNodeChangedJavascript="treeCategoriesSelectedNodeChanged"
                            Height="300">
                        </NineRays:FlyTreeView>
                    </td>
                    <td valign="top">
                        <asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearch">
                            <table border="0" cellpadding="0" cellspacing="5">
                                <tr>
                                    <td>
                                        Login Time
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtStartDate" runat="server" Width="79px" MaxLength="50"></asp:TextBox><asp:Label
                                            ID="lbend" runat="server" Text="~" Style="margin-left: 5px; margin-right: 6px"></asp:Label><asp:TextBox
                                                ID="txtEndDate" runat="server" Width="79px" MaxLength="50"></asp:TextBox>
                                        <asp:CalendarExtender ID="txtStartDate_CalendarExtender" runat="server" Enabled="True"
                                            TargetControlID="txtStartDate">
                                        </asp:CalendarExtender>
                                        <asp:CalendarExtender ID="txtEndDate_CalendarExtender" runat="server" Enabled="True"
                                            TargetControlID="txtEndDate">
                                        </asp:CalendarExtender>
                                    </td>
                                    <td valign="bottom" style="padding-left: 10px">
                                        <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search">
                                        </asp:Button>
                                        <asp:Button ID="btnDelete" runat="server" OnClientClick="showBulkDelete();return false;"
                                            SkinID="Button120" Text="Bulk Delete"></asp:Button>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        User
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtUser" runat="server" MaxLength="50"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </asp:Panel>
                        <div style="margin-top: 10px">
                            <vs:GridView ID="gridLogs" runat="server" AutoGenerateColumns="False" AllowSorting="true"
                                OnRowDataBound="gridLogs_RowDataBound" OnRowCommand="gridLogs_RowCommand">
                                <Columns> 
                                    <vs:TemplateField HeaderText="User Name" SortExpression="UserName">
                                        <ItemTemplate>
                                            <%# Eval("UserName")%>
                                        </ItemTemplate>
                                    </vs:TemplateField>
                                    <vs:TemplateField HeaderText="Login Time" SortExpression="LogTime" ItemStyle-Width="120px">
                                        <ItemTemplate>
                                            <%# Eval("LogTime","{0:"+ApplicationConfiguration.DateTimeFormat+"}") %>
                                        </ItemTemplate>
                                    </vs:TemplateField>
                                    <vs:TemplateField HeaderText="Logout Time" SortExpression="LogOutTime">
                                        <ItemTemplate>
                                            <%# Eval("LogOutTime","{0:"+ApplicationConfiguration.DateTimeFormat+"}") %>
                                        </ItemTemplate>
                                    </vs:TemplateField>
                                    <vs:TemplateField HeaderText="Duration(minutes)" SortExpression="Duration">
                                        <ItemTemplate>
                                            <%# Eval("Duration")%>
                                        </ItemTemplate>
                                    </vs:TemplateField>
                                    <vs:TemplateField HeaderText="IP Address" SortExpression="IPAddress">
                                        <ItemTemplate>
                                            <%# Eval("VistorIP")%>
                                        </ItemTemplate>
                                    </vs:TemplateField>
                                    <vs:TemplateField HeaderText="Source" SortExpression="Source" ItemStyle-Width="300px"
                                        Visible="false">
                                        <ItemTemplate>
                                            <%# Eval("Source")%>
                                        </ItemTemplate>
                                    </vs:TemplateField>
                                    <vs:TemplateField HeaderText="Operations" ItemStyle-Width="60px" Visible="false">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnView" runat="server" SkinID="ViewDetail" />
                                            &nbsp;&nbsp;&nbsp;&nbsp;
                                            <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("LogId") %>'
                                                Visible='false' CommandName="DeleteEvent" SkinID="Delete" OnClientClick="javascript:return window.confirm('Do you want to delete this event?');" />
                                        </ItemTemplate>
                                    </vs:TemplateField>
                                </Columns>
                            </vs:GridView>
                        </div>
                        <asp:Button ID="btnChangeCategory" runat="server" OnClick="btnChangeCategory_Click"
                            SkinID="Hidden" />
                        <uc1:GridPager ID="pagerLogs" runat="server" TargetControlID="gridLogs" PageSize="100"
                            OnPerformGetCondition="pagerLogs_PerformGetCondition" OnPerformGetPageData="pagerLogs_PerformGetPageData"
                            OnPerformGetRecordCount="pagerLogs_PerformGetRecordCount" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
